<?php
/**
 * @version		$Id: form.php 26 2010-09-08 15:30:31Z joomlaworks $
 * @package		K2mart
 * @author    JoomlaWorks http://www.joomlaworks.gr
 * @copyright	Copyright (c) 2006 - 2010 JoomlaWorks, a business unit of Nuevvo Webware Ltd. All rights reserved.
 * @license		Commercial - This code cannot be redistributed without permission from Nuevvo Webware Ltd.
 */

defined('_JEXEC') or die('Restricted access');
?>

<div class="vmForm">
<?php echo $pane->startPane('vmPane'); ?>
	<?php echo $pane->startPanel(JText::_('Product Information'), 'vmProductInfo'); ?>
		<label><?php echo JText::_('Publish?')?></label>
		<input type="checkbox" value="Y" name="product_publish" <?php echo ($product->sf("product_publish")=='Y')? 'checked="checked"':''?>/>
		<br/>
		<label><?php echo JText::_('SKU')?></label>
		<input type="text" maxlength="64" size="32" value="<?php $product->sp("product_sku"); ?>" name="product_sku" class="inputbox" />
		<br/>
		<label><?php echo JText::_('URL')?></label>
		<input type="text" maxlength="255" size="32" value="<?php $product->sp("product_url"); ?>" name="product_url" class="inputbox" />
		<br/>
		<label><?php echo JText::_('Vendor')?></label>
		<?php ps_vendor::list_vendor($product->sf("vendor_id")); ?>
		<?php if($mainframe->isAdmin()):?>
		<a title="<?php echo JText::_('Manage vendors')?>" class="modal vmButton" rel="{handler:'iframe',size:{x:900,y:500}}" href="index.php?pshop_mode=admin&amp;page=vendor.vendor_list&amp;option=com_virtuemart&amp;vmLayout=extended&amp;tmpl=component"><img src="<?php echo JURI::root();?>images/M_images/edit.png" alt="<?php echo JText::_('Manage vendors');?>"/></a>
		<?php endif; ?>
		<br/>
		<label><?php echo JText::_('Manufacturer')?></label>
		<?php ps_manufacturer::list_manufacturer(@$manufacturerID); ?>
		<?php if($mainframe->isAdmin()):?>
		<a title="<?php echo JText::_('Manage manufacturers')?>" class="modal vmButton" rel="{handler:'iframe',size:{x:900,y:500}}" href="index.php?pshop_mode=admin&amp;page=manufacturer.manufacturer_list&amp;option=com_virtuemart&amp;vmLayout=extended&amp;tmpl=component"><img src="<?php echo JURI::root();?>images/M_images/edit.png" alt="<?php echo JText::_('Manage manufacturers');?>"/></a>
		<?php endif; ?>
		<?php if($params->get('categoriesList')):?>
			<br/>
			<label><?php echo JText::_('Categories')?></label><br/>
			<?php $ps_product_category->list_all("product_categories[]", "", $categories, 10, false, true);?>
		<?php else :?>
			<input type="hidden" name="category_ids" value="<?php echo implode('|', array_keys($categories));?>" />
		<?php endif; ?>
	<?php echo $pane->endPanel(); ?>
	<?php echo $pane->startPanel(JText::_('Product Price'), 'vmProductPrice'); ?>
		<label><?php echo JText::_('Product Price (Net)')?></label>
		<input type="text" value="<?php echo @$price["product_price"]; ?>" class="inputbox" name="product_price" onkeyup="updateGross();" size="10" maxlength="10" />
        <input type="hidden" name="product_price_id" value="<?php echo @$price["product_price_id"] ?>" />
        <input type="hidden" name="price_quantity_start" value="<?php echo @intval($price["price_quantity_start"]) ?>" />
        <input type="hidden" name="price_quantity_end" value="<?php echo @intval($price["price_quantity_end"]) ?>" />
		<?php $ps_html->list_currency("product_currency",$price["product_currency"]); ?>
		<img class="hasTip" src="<?php echo JURI::root();?>images/M_images/con_info.png" alt="<?php echo JText::_('Tip')?>" title="<?php echo JText::_('Tip: Shopper Group');?>: <?php echo $shopperGroupName; ?>" />
		<input type="hidden" name="shopper_group_id" value="<?php echo $shopperGroupID; ?>" />
		<br/>
		<label><?php echo JText::_('Product Price (Gross)')?></label>
		<input type="text" class="inputbox" onkeyup="updateNet();" name="product_price_incl_tax" size="10" />
		<br/>
		<label><?php echo JText::_('VAT Id')?></label>
		<?php $tax_rates = ps_tax::list_tax_value("product_tax_id",$product->sf("product_tax_id"),"updateGross();"); ?>
		<?php if($mainframe->isAdmin()):?>
		<a title="<?php echo JText::_('Manage tax rates')?>" class="modal vmButton" rel="{handler:'iframe',size:{x:900,y:500}}" href="index.php?pshop_mode=admin&amp;page=tax.tax_list&amp;option=com_virtuemart&amp;vmLayout=extended&amp;tmpl=component"><img src="<?php echo JURI::root();?>images/M_images/edit.png" alt="<?php echo JText::_('Manage tax rates');?>"/></a>
		<?php endif; ?>
		<script type="text/javascript">
		<?php foreach( $tax_rates as $tax_rate_id => $tax_rate ) :?>
			<?php echo "tax_rates[\"$tax_rate_id\"] = $tax_rate;\n";?>
		<?php endforeach; ?>
		</script>
		<br/>
		<label><?php echo JText::_('Discount Type')?></label>
		<?php echo $discounts; ?>
		<?php if($mainframe->isAdmin()):?>
		<a title="<?php echo JText::_('Manage discounts')?>" class="modal vmButton" rel="{handler:'iframe',size:{x:900,y:500}}" href="index.php?pshop_mode=admin&amp;page=product.product_discount_list&amp;option=com_virtuemart&amp;vmLayout=extended&amp;tmpl=component"><img src="<?php echo JURI::root();?>images/M_images/edit.png" alt="<?php echo JText::_('Manage discounts');?>"/></a>
		<?php endif; ?>
		<img class="hasTip" src="<?php echo JURI::root();?>images/M_images/con_info.png" alt="<?php echo JText::_('Tip')?>" title="<?php echo JText::_('Tip: Here you can override the discount setting fill in a special discount price for this product. The Shop will create a new discount record from the discounted price.');?>" />
		<br/>
		<label><?php echo JText::_('Discounted Price')?></label>
		<input type="text" size="10" name="discounted_price_override" onchange="try { document.adminForm.product_discount_id[document.adminForm.product_discount_id.length-1].selected=true; } catch( e ) {}" />
		<input type="hidden" name="product_parent_id" value="<?php echo $product->f('product_parent_id');?>"/>
	<?php echo $pane->endPanel(); ?>
	<?php echo $pane->startPanel(JText::_('Product Status'), 'vmProductStatus'); ?>
		<label><?php echo JText::_('In Stock')?></label>
		<input type="text" class="inputbox"  name="product_in_stock" value="<?php $product->sp("product_in_stock"); ?>" size="10" />
		<br/>
		<label><?php echo JText::_('Minimum Purchase Quantity')?></label>
		<input type="text" class="inputbox"  name="min_order_level" value="<?php echo $min_order; ?>" size="10" />
		<br/>
		<label><?php echo JText::_('Maximum Purchase Quantity')?></label>
		<input type="text" class="inputbox"  name="max_order_level" value="<?php echo $max_order; ?>" size="10" />
		<br/>
		<label><?php echo JText::_('Availability Date')?></label>
		<?php echo JHTML::_('calendar',$availabilityDate, 'product_available_date', 'product_available_date', '%Y-%m-%d'); ?>
		<br/>
		<label><?php echo JText::_('Availability')?></label>
		<input type="text" class="inputbox"  name="product_availability" value="<?php $product->sp("product_availability"); ?>" size="32" />
		<?php echo JHTML::_('list.images', 'k2martAvailabilityImg', $product->f("product_availability"), ' ', 'components/com_virtuemart/themes/default/images/availability/'); ?>
		<img class="hasTip" src="<?php echo JURI::root();?>images/M_images/con_info.png" alt="<?php echo JText::_('Tip')?>" title="<?php echo JText::_('Tip: Fill in any text here that will be displayed to the customer on the product flypage e.g.: 24h, 48 hours, 3 - 5 days, On Order or select an image to be displayed instead. The images reside in the directory /components/com_virtuemart/themes/default/images/availability/');?>" />
		<div id="k2martAvailabilityImgPreview"></div>
		<br/>
		<label><?php echo JText::_('On special')?></label>
		<input type="checkbox" value="Y" name="product_special" <?php echo ($product->sf("product_special")=='Y')? 'checked="checked"':''?>/>
		<?php echo $pane->endPanel(); ?>
	<?php echo $pane->startPanel(JText::_('Product Attributes'), 'vmProductAttributes'); ?>
		<label><?php echo JText::_('Attribute List')?></label>
		<div id="attribute_container"><?php ps_product_attribute::loadAttributeExtension($product->sf("attribute")); ?></div>
		<span class="k2Note">
			<strong><?php echo JText::_('Examples for the Attribute List Format');?>:</strong>
			<br/><?php echo JText::_('Title &#61; Color, Property &#61; Red ; Click on New Property to add a new color: Green ; Then click on New attribute to add a new attribute, and so on.');?><br/>
			<br/><strong><?php echo JText::_('Inline price adjustments for using the Advanced Attributes modification');?>:</strong>
			<br/><?php echo JText::_('Price &#61; +10 to add this amount to the configured price.');?>
			<br/><?php echo JText::_('Price &#61; -10 to subtract this amount from the configured price.');?>
			<br/><?php echo JText::_('Price &#61; 10 to set the product\'s price to this amount.');?>
		</span>
		<br/>
		<label><?php echo JText::_('Custom Attribute List')?></label>
		<input class="inputbox" type="text" name="product_custom_attribute" value="<?php $product->sp("custom_attribute"); ?>" size="64" />
		<span class="k2Note"><strong><?php echo JText::_('Examples for the Custom attribute List Format');?>:</strong> <?php echo JText::_('Name;Extras;...');?></span>
	<?php echo $pane->endPanel(); ?>
	<?php echo $pane->startPanel(JText::_('Product Dimensions and Weight'), 'vmProductDimWeight'); ?>
		<label><?php echo JText::_('Length')?></label>
		<input type="text" class="inputbox"  name="product_length" value="<?php $product->sp("product_length"); ?>" size="15" maxlength="15" />
		<br/>
		<label><?php echo JText::_('Width')?></label>
		<input type="text" class="inputbox"  name="product_width" value="<?php $product->sp("product_width"); ?>" size="15" maxlength="15" />
		<br/>
		<label><?php echo JText::_('Height')?></label>
		<input type="text" class="inputbox"  name="product_height" value="<?php $product->sp("product_height"); ?>" size="15" maxlength="15" />
		<br/>
		<label><?php echo JText::_('Unit of Measure')?></label>
		<input type="text" class="inputbox"  name="product_lwh_uom" value="<?php $product->sp("product_lwh_uom"); ?>" size="8" maxlength="32" />
		<br/><hr class="vmSeperator" />
		<label><?php echo JText::_('Weight')?></label>
		<input type="text" class="inputbox"  name="product_weight" size="15" maxlength="15" value="<?php $product->sp("product_weight"); ?>" />
		<br/>
		<label><?php echo JText::_('Unit of Measure')?></label>
		<input type="text" class="inputbox"  name="product_weight_uom" value="<?php $product->sp("product_weight_uom"); ?>" size="8" maxlength="32" />
		<br/><hr class="vmSeperator" />
		<label><?php echo JText::_('Unit')?></label>
		<input type="text" class="inputbox"  name="product_unit" size="15" maxlength="15" value="<?php $product->sp("product_unit"); ?>" />
		<br/>
		<label><?php echo JText::_('Units in a Package')?></label>
		<input type="text" class="inputbox"  name="product_packaging" value="<?php echo $product->f("product_packaging") & 0xFFFF; ?>" size="8" maxlength="32" />
		<img class="hasTip" src="<?php echo JURI::root();?>images/M_images/con_info.png" alt="<?php echo JText::_('Tip')?>" title="<?php echo JText::_('Tip: Here you can fill in the number of units in a package. (max. 65535)');?>" />
		<br/>
		<label><?php echo JText::_('Units in Box')?></label>
		<input type="text" class="inputbox"  name="product_box" value="<?php echo ($product->f("product_packaging")>>16)&0xFFFF; ?>" size="8" maxlength="32" />
		<img class="hasTip" src="<?php echo JURI::root();?>images/M_images/con_info.png" alt="<?php echo JText::_('Tip')?>" title="<?php echo JText::_('Tip: Here you can fill in the number of units in a box. (max. 65535)');?>" />
		<br/>
	<?php echo $pane->endPanel(); ?>
	<?php if($params->get('toolsTab')):?>
	<?php echo $pane->startPanel(JText::_('Tools'), 'vmProductTools'); ?>
		<div>
			<label for="vmAssign"><?php echo JText::_('Assign product');?></label> <input value="1" id="vmAssign" name="vmAssign" type="checkbox"/>
			<input class="text_area" value="<?php echo $productID; ?>" name="product_id" type="text"/>
			<span class="k2Note"><?php echo JText::_('Check this and type a virtuemart product ID to assign an existing virtuemart product to the K2 item. Mind that this will override all the above settings!');?></span>
		</div>
		<br/>
		<div>
			<label for="vmUnassign"><?php echo JText::_('Unassign product');?></label> <input value="1" id="vmUnassign" name="vmUnassign" type="checkbox"/>
			<span class="k2Note"><?php echo JText::_('Check this to remove any relation between this K2 item and virtuemart product');?></span>
		</div>
		<br/>
		<div>
			<label for="vmRemove"><?php echo JText::_('Remove product');?></label> <input value="1" id="vmRemove" name="vmRemove" type="checkbox"/>
			<span class="k2Note"><?php echo JText::_('This will delete the virtuemart product! Use with care!');?></span>
		</div>
	<?php echo $pane->endPanel(); ?>
	<?php else: ?>
		<input value="<?php echo $productID; ?>" name="product_id" type="hidden"/>
	<?php endif; ?>
<?php echo $pane->endPane(); ?>
</div>
